﻿@using Projectmanagement.Entity
@using ProjectManagement.Models
@using Projectmanagement.Utl
@model DateTime
@{
    var sdt = Helpers.GetFirstDivDateTime(Model);
    var tasts = ViewBag.tasks as IQueryable<Task>;
}
<style>
    .fc-day-content > div
    {
        position: relative;
        line-height: 21px;
        word-break: break-all;
        border: 3px solid white;
        background-color: #36c;
        font-size: 12px;
        padding: 0 3px;
        color: #fff;
    }
    .fc-day-content > div a
    {
        font-size: 12px;
        color: #fff;
        font-family: "微软雅黑" , "Helvetica Neue" , Helvetica, Arial, sans-serif;
        text-decoration: none;
    }
    .fc-day-number
    {
        padding: 0 2px;
        font-size: 12px;
        text-align: right;
        font-weight: bold;
    }
    .fc-day-hide
    {
        opacity: 0.3;
        filter: alpha(opacity=30);
    }
    .fc-border-separate td
    {
        border-width: 1px 0 0 1px;
        padding: 0;
        vertical-align: top;
        border: solid 1px white;
    }
    .fc-first th
    {
        text-align: center;
        font-weight: normal;
    }
    .fc-border-separate th, .fc-border-separate td
    {
        border-width: 1px 0 0 1px;
        background-color: #ECECEC;
    }
    .fc-border-separate th
    {
        padding: 0;
        vertical-align: top;
    }
    #fc-main
    {
        padding: 20px;
        font-family: "Helvetica Neue" , Helvetica, Arial, sans-serif;
        background: #eee;
        border: 1px solid #7F9DB9;
    }
    #fc-box
    {
        width: 900px;
        margin: auto;
        border: 1px solid #a6a6a6;
        -webkit-border-radius: 3px 3px 3px 3px;
        -moz-border-radius: 3px 3px 3px 3px;
        border-radius: 3px 3px 3px 3px;
        background: #fff;
    }
    #fc-box-head
    {
        color: #595959;
        padding: 6px 8px 6px 15px;
        border-bottom: 1px solid #a6a6a6;
        background-color: #f5f5f5;
        background-image: -moz-linear-gradient(top, #fafafa, #ededed);
        background-image: -ms-linear-gradient(top, #fafafa, #ededed);
        background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fafafa), to(#ededed));
        background-image: -webkit-linear-gradient(top, #fafafa, #ededed);
        background-image: -o-linear-gradient(top, #fafafa, #ededed);
        background-image: linear-gradient(top, #fafafa, #ededed);
        background-repeat: repeat-x;
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafa', endColorstr='#ededed', GradientType=0);
        -webkit-border-radius: 3px 3px 0 0;
        -moz-border-radius: 3px 3px 0 0;
        border-radius: 3px 3px 0 0;
    }
    .fc-box-content
    {
        padding: 0;
        background: #fff;
        -webkit-border-radius: 0 0 2px 2px;
        -moz-border-radius: 0 0 2px 2px;
        border-radius: 0 0 2px 2px;
    }
    .fc-header
    {
        border-collapse: collapse;
        border-spacing: 0;
        background: #eee;
        border-spacing: 2px;
        text-align: center;
        border-color: gray;
        width: 100%;
    }
    .fc-header-title div
    {
        margin-top: 0;
        white-space: nowrap;
        font-size: 30px;
        line-height: 40px;
        font-weight: bold;
    }
    .fc-view
    {
        width: 100%;
        overflow: hidden;
    }
    table.fc-border-separate
    {
        border-collapse: separate;
    }
    .fc-border-separate td:hover
    {
        background-color: #FFFFCC;
    }
</style>
<div id="fc-main">
    <div id="fc-box">
        <div id="fc-box-head">
            @ViewBag.Title
        </div>
        <div class="fc-box-content">
            <div>
                <table class="fc-header" style="width: 100%">
                    <tbody>
                        <tr>
                            <td class="fc-header-left" style="width: 30%">
                            </td>
                            <td class="fc-header-center">
                                <b class="fc-header-title" style="color: #000;">
                                    @Model.ToString("yyyy年MM月")
                                </b>
                            </td>
                            <td class="fc-header-right" style="width: 30%">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="fc-box-content" style="position: relative; min-height: 1px;">
            <div class="fc-view" style="position: relative;">
                <table cellspacing="0" style="width: 100%; font-family: Microsoft Sans Serif; color: #000;"
                    class="fc-border-separate">
                    <thead>
                        <tr class="fc-first">
                            <th style="width: 127px;">
                                <b>星期天</b>
                            </th>
                            <th style="width: 127px;">
                                <b>星期一</b>
                            </th>
                            <th style="width: 127px;">
                                <b>星期二</b>
                            </th>
                            <th style="width: 127px;">
                                <b>星期三</b>
                            </th>
                            <th style="width: 127px;">
                                <b>星期四</b>
                            </th>
                            <th style="width: 127px;">
                                <b>星期五</b>
                            </th>
                            <th>
                                <b>星期六</b>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @for (var i = 0; i < 5; i++)
                        {
                            <tr>
                                @for (var j = 0; j < 7; j++)
                                {
                                    DateTime dt = sdt.AddDays(i * 7 + j);
                                    string style = "";
                                    if (dt.Date.Equals(Model))
                                    {
                                        style = "style=background-color:#FFFFCC;";
                                    }
                                    
                                    <td @style>
                                        <div>
                                            <div class="fc-day-number @(dt.ToString("MM").Equals(Model.ToString("MM")) ? "" : "fc-day-hide")">
                                                @dt.ToString("dd")
                                            </div>
                                            <div class="fc-day-content" style="height: 90px; overflow: auto;">
                                                @if (tasts != null)
                                                {
                                                    foreach (var x in tasts)
                                                    {
                                                        string statusImage = "white";
                                                        if (x.TaskState != null)
                                                        {
                                                            if (x.StartDate > DateTime.Now)
                                                            {
                                                                if (x.TaskState.Code == 100)
                                                                {
                                                                    /*绿色*/
                                                                    statusImage = "#01AD0D";

                                                                }
                                                                else
                                                                {
                                                                    statusImage = "white";
                                                                }
                                                            }
                                                            else if (x.StartDate < DateTime.Now && x.EndDate >= DateTime.Now)
                                                            {
                                                                if (x.TaskState.Code == 100)
                                                                {
                                                                    statusImage = "#01AD0D";
                                                                }
                                                                else
                                                                {
                                                                    /*蓝色*/
                                                                    statusImage = "#5847BC";
                                                                }
                                                            }
                                                            else if (x.EndDate < DateTime.Now)
                                                            {
                                                                if (x.TaskState.Code == 100)
                                                                {
                                                                    statusImage = "#01AD0D";
                                                                }
                                                                else
                                                                {
                                                                    /*红色*/
                                                                    statusImage = "#F2140F";
                                                                }
                                                            }

                                                            switch (x.TaskState.Code)
                                                            {
                                                                case 90:
                                                                    /*黄色*/
                                                                    statusImage = "#D88201";
                                                                    break;
                                                                case -1:
                                                                case -10:
                                                                    /*灰色*/
                                                                    statusImage = "#696766";
                                                                    break;
                                                            }
                                                        }

                                                        if (x.EndDate.ToString("yyyy/MM/dd").Equals(dt.ToString("yyyy/MM/dd")))
                                                        {
                                                    
                                                    <div style="background-color:@statusImage ">
                                                        @if (statusImage == "white")
                                                        {
                                                            <a href="javascript:;" onclick="showtask(@x.ID)" style="color:#000">
                                                                @x.Name (@x.FinishPer) </a>
                                                        }
                                                        else
                                                        {
                                                            <a href="javascript:;" onclick="showtask(@x.ID)">
                                                                @x.Name (@x.FinishPer) </a>
                                                        }
                                                    </div>
                                                        }
                                                    }
                                                }
                                            </div>
                                        </div>
                                    </td>
                                }
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
